package com.ruoyi.web.controller.supermarket;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.supermarket.domain.SupermarketStaff;
import com.ruoyi.supermarket.service.ISupermarketStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 超市员工详细信息Controller
 * 
 * @author faye
 * @date 2024-06-01
 */
@RestController
@RequestMapping("/supermarket/staff")
public class SupermarketStaffController extends BaseController
{
    @Autowired
    private ISupermarketStaffService supermarketStaffService;

    /**
     * 查询超市员工详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:staff:list')")
    @GetMapping("/list")
    public TableDataInfo list(SupermarketStaff supermarketStaff)
    {
        startPage();
        List<SupermarketStaff> list = supermarketStaffService.selectSupermarketStaffList(supermarketStaff);
        return getDataTable(list);
    }

    /**
     * 导出超市员工详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:staff:export')")
    @Log(title = "超市员工详细信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SupermarketStaff supermarketStaff)
    {
        List<SupermarketStaff> list = supermarketStaffService.selectSupermarketStaffList(supermarketStaff);
        ExcelUtil<SupermarketStaff> util = new ExcelUtil<SupermarketStaff>(SupermarketStaff.class);
        util.exportExcel(response, list, "超市员工详细信息数据");
    }

    /**
     * 获取超市员工详细信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:staff:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(supermarketStaffService.selectSupermarketStaffById(id));
    }

    /**
     * 新增超市员工详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:staff:add')")
    @Log(title = "超市员工详细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SupermarketStaff supermarketStaff)
    {
        return toAjax(supermarketStaffService.insertSupermarketStaff(supermarketStaff));
    }

    /**
     * 修改超市员工详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:staff:edit')")
    @Log(title = "超市员工详细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SupermarketStaff supermarketStaff)
    {
        return toAjax(supermarketStaffService.updateSupermarketStaff(supermarketStaff));
    }

    /**
     * 删除超市员工详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:staff:remove')")
    @Log(title = "超市员工详细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(supermarketStaffService.deleteSupermarketStaffByIds(ids));
    }
}
